package com.fourmob.poppyview.sample.slice;

import com.fourmob.poppyview.sample.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_activity_main);
        Button button1 = (Button) findComponentById(ResourceTable.Id_button1);
        Button button2 = (Button) findComponentById(ResourceTable.Id_button2);
        button1.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.example.poppyview")
                        .withAbilityName("com.fourmob.poppyview.sample.ListViewAbility")
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent); 

            }
        });
        button2.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent secondIntent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("com.example.poppyview")
                        .withAbilityName("com.fourmob.poppyview.sample.ScrollViewAbility")
                        .build();
                secondIntent.setOperation(operation);
                startAbility(secondIntent);
            }
        });

    }

    @Override
    public void onActive() {
        super.onActive();
    }

}
